<template>
  <div style="padding: 20px;">
    <el-card class="box-card" shadow="hover" style="display: flex;flex-direction: column;">
      <div> <el-button type="primary" size="small" @click="download">
          下载模版文件
        </el-button></div>
      <div>
        <el-button type="primary" size="small" @click="downloadData">
          下载当前数据
        </el-button>
        <el-upload :show-file-list="false" action="" :before-upload="beforeAvatarUpload">
          <el-button type="primary" size="small">
            上传模版文件
          </el-button>
        </el-upload>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { myUploadFile } from '@/utils/uploadFile';
import { reactive } from 'vue';
const state = reactive({
  baseUrl: import.meta.env.VITE_API_URL,
})

const beforeAvatarUpload = (file: any) => {
  myUploadFile(file, `${state.baseUrl}/upload`, 'file', '上传成功')
}

const download = () => {
  // downloadFile('GET', `${state.baseUrl}/download`,'', '模版')
  window.open(`${state.baseUrl}/template`)
}

const downloadData = () => {
  window.open(`${state.baseUrl}/data`)
}
</script>
  